import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'


// https://vitejs.dev/config/
export default defineConfig({
    // server: {
    //     open:true, //自动浏览
    //     port:8088, //端口号
    //     host:'192.168.101.148'
    // },
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      },
    },
    plugins: [
      vue(),
      Components({
        dts: false, //不自动生成组件类型文件 导入包后就能识别
        // importStyle: false 不自动导入样式，已经在main.ts导入
        resolvers: [VantResolver({ importStyle: true })]
      }),
    ],
    define: {
        'process.env': {
          'VUE_APP_BASE_API':"http://192.168.101.148:8088/pesweb/cloud"
        }
    },
    devServer: {
        host: '0.0.0.0',
        https: false,
        open: true,
        disableHostCheck: true, 
    },
    server: applyServerConfig(serverConfig, {
        // 在这里添加额外的参数
        https: true, // 启用HTTPS
        proxy: {
          // 配置代理规则
          '/api': {
            target: 'http://api.example.com',
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, '')
          }
        }
      })
})
